package com.zgjkhis.modules.charges.domain;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.NotNull;
import java.util.Date;

/**
 * @Author yxl
 * @Description
 * @Date 2021/7/20 9:32
 **/
@Data
@NoArgsConstructor
@TableName("his_logistics_route")
public class LogisticsRoute {

    @TableId
    private Long id;

    /** 创建时间 */
    @TableField(fill= FieldFill.INSERT)
    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    private Date createTime;

    @ApiModelProperty(value = "药房id",required = true)
    @NotNull(message = "药房id不能为空")
    private String pharmacyId;

    @ApiModelProperty(value = "业务订单号")
    private String bspOrderNo;

    @ApiModelProperty(value = "顺丰单号")
    private String mailNo;

    @ApiModelProperty(value = "已到达地址")
    private String acceptAddress;

    // 80-已签收，其他状态码请参考:https://qiao.sf-express.com/pages/developDoc/index.html?level2=949000
    @ApiModelProperty(value = "路由信息操作码,80代表已签收")
    private Integer opcode;

    @ApiModelProperty(value = "到达时间")
    private String acceptTime;

    @ApiModelProperty(value = "备注")
    private String remark;

    public LogisticsRoute(JSONObject json) {
        this.mailNo = json.getString("mailno");
        this.acceptAddress = json.getString("accept_address");
        this.acceptTime = json.getString("accept_totaltime");
        this.remark = json.getString("remark");
        this.opcode = json.getInteger("opcode");
    }

    public LogisticsRoute(JSONObject json, Logistics logistics) {
        this(json);
        this.pharmacyId = logistics.getPharmacyId();
        this.bspOrderNo = logistics.getBspOrderNo();
    }
}
